﻿
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>壁纸添加</title>


<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="shortcut icon"
	href="${pageContext.request.contextPath}/favicon.ico">
<!-- Animate.css -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/animate.css">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/icomoon.css">
<!-- Bootstrap  -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.css">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/style.css">

<!-- jQuery -->
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="${pageContext.request.contextPath}/js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script
	src="${pageContext.request.contextPath}/js/jquery.waypoints.min.js"></script>

<!-- Main JS (Do not remove) -->
<script src="${pageContext.request.contextPath}/js/main.js"></script>


<!-- Modernizr JS -->
<script
	src="${pageContext.request.contextPath}/js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
	<script src="../js/respond.min.js"></script>
	<![endif]-->


<style type="text/css">
.content {
	text-align: center;
	color: forestgreen;
}

.content {
	margin-left: 20%;
}

.logo {
	width: 50px;
	height: 50px;
}
</style>



</head>
<body>
	<script>
		//	function regist(){
		//		var title = $("#title").val();
		//		var author = $("#author").val();
		//		var content = $("#content").val();
		//	var urlpicture = $("#urlpicture").val();

		//		$.ajax({
		//			url:"/NewsManager/news/addnews",
		//			type:"POST",				
		//			data:{
		//				"title":title,
		//				"author":author,
		//				"content":content,
		//"urlpicture":urlpicture,
		//				},
		//			contentType:"multipart/form-data",
		//		dataType:"json",
		//			success:function(data){
		//			window.location.href="${pageContext.request.contextPath}/news/getindex";
		//			},
		//			error:function(){

		//			}
		//		});
		//	}

		//上传格式
		function fileChange(target) {

			var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
			var fileSize = 0;
			if (isIE && !target.files) {
				var filePath = target.value;
				var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
				var file = fileSystem.GetFile(filePath);
				fileSize = file.Size;
			} else {
				fileSize = target.files[0].size;
			}
			var size = fileSize / 1024;
			if (size > 2000) {
				$("#error").empty();
				var e = "附件不能大于2M";
				$("#error").append(e);
				return false;
			}
			var name = target.value;
			var fileName = name.substring(name.lastIndexOf(".") + 1)
					.toLowerCase();
			if (fileName != "jpg" && fileName != "jpeg" && fileName != "pdf"
					&& fileName != "dwg" && fileName != "gif") {
				$("#error").empty();
				var e = "请选择图片格式文件上传(jpg,gif,dwg,pdf,gif等)！";
				$("#error").append(e);
				return false;
			} else {

				//设置异步提交成功的回调函数
				var options = {
					success : function(data) {
						window.location.href = "${pageContext.request.contextPath}/system/news/getindex";
					},
					error : function() {
						alert("请登陆");
					}
				};

				// 将表单异步化，
				$("#form1").ajaxForm(options);
				return true;
			}
		}

		$(function() {
			$
					.ajax({
						url : "${pageContext.request.contextPath}/system/category/getAllCategory",
						type : "GET",
						dataType : "json",
						success : function(data) {
							$("#cate").empty();
							for ( var i = 0; i < data.length; i++) {
								var cate = '<option  value="'+data[i].cid+'">'
										+ data[i].p_category + '</option>';
								$("#cate").append(cate);
							}
						},
						error : function() {
							alert("error");
						}
					});

		});
	</script>

	<div class="box-wrap">
		<header role="banner" id="fh5co-header">
			<div class="container">
				<nav class="navbar navbar-default">
					<div class="row">
						<div class="col-md-3">
							<div class="fh5co-navbar-brand">
								<a class="fh5co-logo"
									href="${pageContext.request.contextPath}/html/index.html">
									<img class="logo"
									src="${pageContext.request.contextPath}/images/logo.png"
									title="壁纸之家">
								</a>
							</div>
						</div>
						<div class="col-md-6">
							<ul class="nav text-center">
								<li><a
									href="${pageContext.request.contextPath}/system/news/toindex"><span>壁纸大全</span>
								</a>
								</li>
								<li class="active"><a
									href="${pageContext.request.contextPath}/system/news/toaddnews">壁纸添加</a>
								</li>
								<li><a
									href="${pageContext.request.contextPath}/system/news/toservice">壁纸分类</a>
								</li>
								<li><a
									href="${pageContext.request.contextPath}/system/news/tomynews">我的壁纸</a>
								</li>
							</ul>
						</div>
						<div class="col-md-3">
							<div class="fh5co-navbar-brand">
								<a href="${pageContext.request.contextPath}/system/user/tologin"
									title="登录"> LOGIN</a>
							</div>
						</div>
					</div>
				</nav>
			</div>
		</header>
		<!-- END: header -->
		<section id="intro">
			<div class="container">
				<div class="row">
					<div
						class="col-lg-6 col-lg-offset-3 col-md-8 col-md-offset-2 text-center">
						<div class="intro animate-box">
							<h2>更 多 精 美 壁 纸 尽 在 壁 纸 之 家</h2>
						</div>
					</div>
				</div>
			</div>
		</section>
		<section id="work">
			<div class="container">
				<div class="col-md-6 content">
					<div class="animate-box next">
						<div class="content" href="#">
							<div class="work-title">
								<form
									action="${pageContext.request.contextPath}/system/news/addnews"
									enctype="multipart/form-data" method="post" id="form1"
									class="bs-example bs-example-form">
									<div class="form-group ">
										<div id="error" style="color: red;"></div>
									</div>

									<div class="input-group input-group-lg">
										<span class="input-group-addon glyphicon glyphicon-fire"></span>
										<input type="text" class="form-control" name="title"
											placeholder="标题:">
									</div>

									<br />
									<div class="input-group input-group-lg">
										<span class="input-group-addon glyphicon glyphicon-pencil"></span>
										<input type="text" class="form-control" name="content"
											placeholder="内容:">
									</div>
									<br />
									<div class="input-group input-group-lg">
										<span class="input-group-addon glyphicon glyphicon-tasks"></span>
										<select name="c_id" id="cate"
											style="width: 300px; margin-top: 10px;"></select>
									</div>
									<br />
									<div class="input-group input-group-lg">
										<span class="input-group-addon  glyphicon glyphicon-picture"></span>
										<input type="file" name="file" id="file"
											style="margin-left: 10px; margin-top: 5px;"
											onchange="fileChange(this);" />
									</div>
									<br />

									<!-- <input type="button" value="上传" onclick="regist()" /> -->
									<button type="submit" class="btn btn-primary btn-lg btn-block">上传</button>

								</form>
							</div>
						</div>
					</div>
				</div>

			</div>
		</section>
		<footer id="footer" role="contentinfo">
			<div class="container">
				<div class="row">
					<div class="col-md-12 text-center ">
						<div class="footer-widget border">
							<p class="pull-left">
								<small>&copy;The home of the wallpaper</small>
							</p>
							<p class="pull-right">
								<small> Designed by <a href="#">WSG</a> The home of the
									wallpaper <a href="#" target="_blank">壁纸之家</a> - Worth having</small>
							</p>

						</div>
					</div>
				</div>
			</div>
		</footer>
	</div>
	<!-- END: box-wrap -->

</body>
</html>

